import zipfile
import os
excel_file = 'driver.xlsx'  # 改为你的 Excel 文件路径
with zipfile.ZipFile(excel_file, 'r') as z:  # 打开 Excel 文件
    # 遍历 ZIP 文件中的文件
    for file_name in z.namelist():
        if file_name.startswith('xl/media/'):  # 检查是否是图片文件
            image_name = os.path.basename(file_name)  # 提取文件名
            # 提取图片并保存到当前目录
            with z.open(file_name) as image_file:
                with open(image_name, 'wb') as f:
                    f.write(image_file.read())
            print(f"图片已保存为 {image_name}")